package com.坦克大战.Tank_2;

public class Tank {
    private int x;
    private int y;
    private int direction = 0;  //方向
    private int speed = 1;
    public Tank(int x, int y, int speed) {
        this.x = x;
        this.y = y;
        this.speed = speed;
    }
    public void moveUP() {
        direction = 0;
        if(y <=0) return;
        y -= speed;
    }
    public void moveDOWN(int height) {
        direction = 2;
        if(y >=height-70) return;
        y += speed;

    }
    public void moveLEFT() {
        direction = 1;
        if(x <=0) return;
        x -= speed;

    }
    public void moveRIGHT(int width) {
        direction = 3;
        if(x >=width-70)
            return;
        x += speed;
    }
    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDirection() {
        return direction;
    }
    public void setDirection(int direction) {
        this.direction = direction;
    }

    @Override
    public String toString() {
        return x+"-"+y;
    }


}
